package com.downloading.bezoyaapp.getData;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.util.Log;

import com.downloading.bezoyaapp.support.utils.Constraints;

public class WebServiceAccess {

	private static final String NAMESPACE = "http://server.bezoyaappwebserver.downloading.com/";
	private static String URL = "http://192.168.1.36:8888/bezoyaappwebserver/webservice";
	private static final String METHOD_NAME = "checkPreguntasFromUserId";
	private static final String SOAP_ACTION = "http://server.bezoyaappwebserver.downloading.com/checkPreguntasFromUserId";

	public void prueba() {

		SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

		PropertyInfo propInfo = new PropertyInfo();

		propInfo.name = "arg0";
		propInfo.type = PropertyInfo.STRING_CLASS;

		request.addPropertyIfValue(propInfo, "John Smith");

		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		envelope.dotNet = false;
		envelope.setOutputSoapObject(request);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

		try {

			Log.i("BezoyaApp", envelope.toString());
			androidHttpTransport.call(SOAP_ACTION, envelope);

			SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope
					.getResponse();

			Log.i(Constraints.TAG,
					"resultado Web Service: " + resultsRequestSOAP.toString());

		} catch (Exception e) {

			System.out.print(e.getMessage());

			Log.i("BezoyaApp", e.getMessage());
		}
	}

}
